<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-3.1.1.js"></script>
<script type="text/javascript">
	function sendJson() {
		$.ajax({
			url : "${pageContext.request.contextPath }/requestJson.action",
			type : "post",
			contentType : "application/json;charset=utf-8",
			data : '{"name":"手机","price":"1999"}',
			success : function(data) {
				alert(data);
			}
		})
	}

	function sendkv() {
		$.ajax({
			url : "${pageContext.request.contextPath }/responseJson.action",
			type : "post",
			data : "name=手机&&price=1999",
			success : function(data) {
				alert(data);
			}
		})
	}
</script>
<title>发送json</title>
</head>
<body>
	<input type="button" value="发送json" onclick="sendJson()">
	<input type="button" value="发送key-value" onclick="sendkv()">
</body>
</html>